#!/usr/bin/env python

import sys
import os


try:
  # attempt to use the installed python package
  from bbvisa2ofx import bbvisa2ofx
except:
  # attempt to run the package from the source directory
  sys.path.insert (0,'src')
  from bbvisa2ofx import bbvisa2ofx
  
def main():
	args = sys.argv
	if(len(args) >= 2):
		pathTxt = sys.argv[1]
		if(not os.path.isfile(pathTxt)):
			print "File to convert must exists: %s" % pathTxt
		else:
			pathOfx = pathTxt + ".ofx"
			bbvisa2ofx.convert(pathTxt,pathOfx)
	else:
		print "USAGE: bbvisa2ofx <file to convert>"	
	
	

if __name__ == '__main__':
  main()